home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / Aidan's Class Libraries / Source / Layout Classes / StyleBox.cpp < prev    next >
Encoding:
Text File  |  1997-07-20  |  1.2 KB  |  66 lines  |  [TEXT/CWIE]

  1. //Copyright (c) 1997 Aidan Cully
  2. //All rights reserved
  3.  
  4. #include "CLStyleBox.h"
  5. #include <Resources.h>
  6. #include "CLBaseWindow.h"
  7.  
  8. TStyleBox::TStyleBox(
  9.   TLayoutBranch *super,
  10.   short resID
  11.   ):
  12.     TWindowDrawer( super ),
  13.     mResID( resID )
  14. {
  15.     mPos.h= 0;
  16.     mPos.v= 0;
  17.     mHeight= 0;
  18. }
  19.  
  20. void TStyleBox::AttachedToWindow(
  21.   TBaseWindow *win,
  22.   Rect size
  23.   )
  24. {
  25.     TWindowDrawer::AttachedToWindow( win, size );
  26.     ::InsetRect( &size, 2, 1 );
  27.     mTE= TEStyleNew( &size, &size );
  28.     HidePen();
  29.     Handle tData;
  30.     StScrpHandle sData;
  31.     tData= ::GetResource( 'TEXT', mResID );
  32.     sData= (StScrpHandle)::GetResource( 'styl', mResID );
  33.     HLock( tData );
  34.     TEStylInsert( (*tData), GetHandleSize( tData ), sData, mTE );
  35.     HUnlock( tData );
  36.     ReleaseResource( tData );
  37.     ReleaseResource( (Handle)sData );
  38.     mHeight= TEGetHeight( (**mTE).nLines, 0, mTE );
  39.     (**mTE).inPort= win->GetWindow();
  40.     ShowPen();
  41. }
  42.  
  43. void TStyleBox::ScrollTo(
  44.   short h,
  45.   short v
  46.   )
  47. {
  48.     mWindow->GetDrawFocus();
  49.     TEScroll( h-mPos.h, v-mPos.v, mTE );
  50.     mWindow->ReleaseDrawFocus();
  51.     mPos.h= h;
  52.     mPos.v= v;
  53. }
  54.  
  55. void TStyleBox::DrawWindowSelf(
  56.   TBaseWindow *gr
  57.   )
  58. {
  59.     Rect foo= GetLocalRect();
  60.     TEUpdate( &foo, mTE );
  61. }
  62.  
  63. Rect TStyleBox::GetLargestSize()
  64. {
  65.     return( mContentRect );
  66. }